#include "cCUIApp.h"

cCUIApp::cCUIApp(cCUIWindow *mainWindow)
{
	mainWin = mainWindow;
	init = true;

	windowHandle = mainWin->getWindow();

	//Initialise DevIL
	ilInit();
	iluInit();
	ilutRenderer(ILUT_OPENGL);

	glfwMakeContextCurrent(windowHandle);
}

cCUIApp::~cCUIApp()
{
	glfwTerminate();
}

void cCUIApp::run()
{
	if(init)
	{
		mainWin->show(true);
		init = false;
	}
	while(!glfwWindowShouldClose(windowHandle))
	{
		mainWin->update();
		glfwSwapBuffers(windowHandle);
		mainWin->pollEvents();
	}
}